import coin.exchange.base.kr_rest.native_public_client_base as npubcb


class KorbitNativePublicClient(npubcb.NativePublicClientBase):
  def __init__(self, timeout=50):
    npubcb.NativePublicClientBase.__init__(self, url="https://api.korbit.co.kr/v1", timeout=timeout)

  def get_detailed_ticker(self, currency_pair):
    return self._get_as_json("ticker/detailed", params=dict(currency_pair=currency_pair))

  def get_all_detailed_ticker(self):
    return self._get_as_json("ticker/detailed/all")

  def get_orderbook(self, currency_pair):
    return self._get_as_json("orderbook", params=dict(currency_pair=currency_pair))

  def get_exchange_constants(self):
    return self._get_as_json("constants")

  def get_filled_orders(self, currency_pair, time_period):
    assert time_period in ['minute', 'hour', 'day'], 'Wrong time period value!'
    params = dict(currency_pair=currency_pair, time=time_period)
    return self._get_as_json("transactions", params=params)

  def queryAll(self):
    currency = "btc_krw"
    print(self.get_orderbook(currency))


if __name__ == "__main__":
  client = KorbitNativePublicClient()
  client.queryAll()
